Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stat-mode

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stat-mode

Offers convenient getters and setters for the stat `mode`

  • 0.2.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is stat-mode?

The stat-mode npm package is used to interpret and manipulate the file mode (permissions) of a file system's stat object. It provides a simple interface to read and modify the permissions of files and directories.

What are stat-mode's main functionalities?

Reading File Permissions

This feature allows you to read the permissions of a file. The code sample demonstrates how to use the stat-mode package to check if the owner can read, the group can write, and others can execute the file 'example.txt'.

const fs = require('fs');
const Mode = require('stat-mode');

fs.stat('example.txt', (err, stats) => {
  if (err) throw err;
  const mode = new Mode(stats);
  console.log(`Owner can read: ${mode.owner.read}`);
  console.log(`Group can write: ${mode.group.write}`);
  console.log(`Others can execute: ${mode.others.execute}`);
});

Modifying File Permissions

This feature allows you to modify the permissions of a file. The code sample shows how to use the stat-mode package to set the read permission for the owner, write permission for the group, and execute permission for others on the file 'example.txt'.

const fs = require('fs');
const Mode = require('stat-mode');

fs.stat('example.txt', (err, stats) => {
  if (err) throw err;
  const mode = new Mode(stats);
  mode.owner.read = true;
  mode.group.write = true;
  mode.others.execute = true;
  fs.chmod('example.txt', mode.stat.mode, (err) => {
    if (err) throw err;
    console.log('Permissions updated');
  });
});

Other packages similar to stat-mode

Keywords

FAQs

Package last updated on 05 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc